export default {
  // 获取页面数据
  getTableData() {
    var parms = {
      page: this.$refs.Page.pagination.current,
      limit: this.$refs.Page.pagination.pageSize
    }

    this.axiosGets("Role/getAllRole", parms, function(res) {

      this.tableData = res.data.data.data
      //分页
      this.total=res.data.data.total
    })
  },

  //添加
  add() {
    // this.history('/admin/edit')
	// this.$refs.editRole.getRoleTree();
	this.$refs.editRole.isShow = true;
  },

  //编辑
  edit(scope) {
    // this.history('/admin/edit?id=' + scope.id)
    // this.$router.push({ name: '管理员edit', params: { info:scope }})
	this.$refs.editRole.roleTree = scope;
	this.$refs.editRole.getRoleTree();
	setTimeout(() => {
		this.$refs.editRole.getRole();
	},300)
	this.$refs.editRole.isShow = true;
  },

  //删除
  remove(scope) {
    this.$confirm('此操作将删除该数据, 是否继续?', '提示', {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      type: 'warning'
    }).then(() => {

      this.sureRemove(scope.id);
    }).catch(() => {
      this.$message({
        type: 'info',
        message: '已取消删除'
      });
    });
  },

  //确定删除
  sureRemove(id){

    this.axiosGets("Role/deleteRole?role_id="+id, {}, function(data) {
      if(data.data.code==0){
        this.getTableData();
        this.msgSuccess(data.data.message)
      }else{
        this.msgError(data.data.message)
      }
    })
  }
}
